#coding:utf-8
from config import cfg
import math
from utils import get_val_on_straight_line
import numpy as np
#def hover_energy()

def flight_energy(d, h, v = None, gt = None, ax = None, use_cgf=True):
	"""
	cruise flight energy consumption
	"""
	if use_cgf:
		return (cfg.W_cruise+(20.682125*(h*cfg.v/d)**3+15.92373*(h*cfg.v/d)**2+118.8195*(h*cfg.v/d)))*d/cfg.v #energy cost of cruise flight
		#return (d**2+h**2)**0.5
	else:
		W_cruise = (0.402*v**3 - 6.2816*v**2 + 11.0257*v)+(gt / ax)*1000/(-0.089*(gt / ax)**3 + 1.1531*(gt / ax)**2 - 5.7839*(gt / ax) + 17.147 )*ax+60
		#return W_cruise*d/v
		return (W_cruise+(20.682125*(h*v/d)**3+15.92373*(h*v/d)**2+118.8195*(h*v/d)))*d/v



